local bochoudu = fk.CreateSkill {
  name = "bochoudu",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["bochoudu"] = "抽督",
  [":bochoudu"] = "锁定技，你的多目标锦囊牌均视为无色【杀】。你使用无色牌无距离和次数限制且可以额外指定任意个目标，然后你当前手牌中的所有伤害牌的伤害基数+1直到回合结束。",

  ["#bochoudu-choose"] = "抽督：你可以为此 %arg 额外指定任意个目标",
  ["@bochoudu-inhand-damage"] = "伤害+",
  
  ["$bochoudu1"] = "万均勇力，斩将拔旗！",
  ["$bochoudu2"] = "虎牢硝烟起，长板水逆流！",
  ["$bochoudu3"] = "骁勇而多权略，攻无不克！"
}

bochoudu:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(bochoudu.name) and data.card.color == Card.NoColor
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    
    -- 遍历手牌，为伤害牌增加伤害标记
    for _, id in ipairs(player:getCardIds("h")) do
      local card = Fk:getCardById(id)
      if card.is_damage_card then
        room:addCardMark(card, "@bochoudu-inhand-damage")
      end
    end
    
    if #data:getExtraTargets({bypass_distances = true}) > 0 then
      local tos = room:askToChoosePlayers(player, {
        targets = data:getExtraTargets({bypass_distances = true}),
        min_num = 1,
        max_num = 9,
        prompt = "#bochoudu-choose:::"..data.card:toLogString(),
        skill_name = bochoudu.name,
        cancelable = true,
      })
      if #tos > 0 then
        room:sortByAction(tos)
        for _, p in ipairs(tos) do
          data:addTarget(p)
        end
        room:sendLog{
          type = "#AddTargetsBySkill",
          from = player.id,
          to = table.map(tos, Util.IdMapper),
          arg = bochoudu.name,
          arg2 = data.card:toLogString(),
        }
      end
    end
  end,
})

bochoudu:addEffect(fk.PreCardUse, {
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card:getMark("@bochoudu-inhand-damage") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    -- 增加伤害基数
    data.additionalDamage = (data.additionalDamage or 0) + data.card:getMark("@bochoudu-inhand-damage")
  end,
})

bochoudu:addEffect(fk.PreCardUse, {
  can_refresh = function(self, event, target, player, data)
    return target == player and data.card.color == Card.NoColor and player:hasSkill(bochoudu.name)
  end,
  on_refresh = function(self, event, target, player, data)
    data.extraUse = true
  end,
})

bochoudu:addEffect("filter", {
  mute = true,
  card_filter = function(self, card, player)
    return player:hasSkill(bochoudu.name) and card.multiple_targets and
      table.contains(player:getCardIds("h"), card.id)
  end,
  view_as = function(self, player, card)
    return Fk:cloneCard("slash", Card.NoSuit, card.number)
  end,
})

bochoudu:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card)
    return card and card.color == Card.NoColor and player:hasSkill(bochoudu.name)
  end,
  bypass_distances = function(self, player, skill, card)
    return card and card.color == Card.NoColor and player:hasSkill(bochoudu.name)
  end,
})

return bochoudu